package cn.bdqn.crm.controller;

import cn.bdqn.crm.domain.vo.SysUserVo;
import cn.bdqn.crm.service.SysUserService;
import cn.bdqn.crm.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private RedisUtil redisUtil;

    @GetMapping("/doLogin")
    public SysUserVo doLogin(
            @RequestParam("userName")
            String userName,
            @RequestParam("userPwd")
            String userPwd ){
        SysUserVo userVo = sysUserService.findByLogin(userName,userPwd);
        return userVo;
    }

    //TOKEN-USER-4F95399DD03E420A8DC020AE016008D3

    @GetMapping("/getToken")
    public SysUserVo getToken(
            @RequestParam("token")
                    String token
            ){
        SysUserVo userVo = (SysUserVo)redisUtil.get(token);
        return userVo;
    }

}
